import React, { Component } from 'react'
import {withRouter} from 'react-router'

class TodoAdd extends Component {
	constructor(){
		super();
		this.add = this.add.bind(this);
	}
	add(){
		this.props.add(this.refs.t.value,this.refs.c.value);
		// console.log( this.props );
		this.props.history.push("/todoList/todos");
	}
  render() {
		return (
			<div>
				<h3>TodoAdd</h3>
				<hr />
				<input type="text" ref="t" />
				<textarea cols="30" rows="10" ref="c"></textarea>
				<button onClick = { this.add }>send</button>
			</div>
		)
  }
}

export default withRouter(TodoAdd)